tonal-notation
tonal-notation
is a collection of functions to create and manipulate strings with music information.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-notation
API Reference
- toStep(letter) ⇒
Integer
Given a letter, return step
- isStep(step) ⇒
Boolean
Test if a number is a valid step number (a number from 0 to 6)
- toLetter(step) ⇒
String
Given a step, return a letter
- areFlats(str) ⇒
Boolean
Test if a string are all flats (b
) chars
- areSharps(str) ⇒
Boolean
Test if a string are all sharps (#
) chars
- toAlt(accidentals) ⇒
Integer
Given an accidentals string return its alteration, the number
of semitones (positive for sharps, negative for flats, 0 for none)
- toAcc(alteration) ⇒
String
Given an alteration number, returns the accidentals string
toStep(letter) ⇒ Integer
Given a letter, return step
Returns: Integer
- the step number (from 0 to 6)
Param | Type | Description |
---|
letter | String | the letter |
isStep(step) ⇒ Boolean
Test if a number is a valid step number (a number from 0 to 6)
Returns: Boolean
- true if it's a valid step number, false otherwise
Param | Type | Description |
---|
step | Integer | the step number |
toLetter(step) ⇒ String
Given a step, return a letter
Returns: String
- the note letter or null if not valid step number
Param | Type | Description |
---|
step | Integer | the step number |
areFlats(str) ⇒ Boolean
Test if a string are all flats (b
) chars
Returns: Boolean
- true if all charaters are b
, false otherwise
Param | Type | Description |
---|
str | String | the string to test |
areSharps(str) ⇒ Boolean
Test if a string are all sharps (#
) chars
Returns: Boolean
- true if all charaters are #
, false otherwise
Param | Type | Description |
---|
str | String | the string to test |
toAlt(accidentals) ⇒ Integer
Given an accidentals string return its alteration, the number
of semitones (positive for sharps, negative for flats, 0 for none)
Returns: Integer
- the alteration number of null if not a valid accidental strings
Param | Type | Description |
---|
accidentals | String | the string to parse |
Example
toAlt('###')
toAlt('bbb')
toAcc(alteration) ⇒ String
Given an alteration number, returns the accidentals string
Returns: String
- the accidental string
Param | Type | Description |
---|
alteration | Integer | the number of semitones (positive and negative values are accepted for sharps and flats) |
Example
toAcc(3)
toAcc(-3)